#include <stdio.h>
#include <string.h>
#include <iostream>
#define MaxSize 600
#define INF 9999999
using namespace std;
int n, m, c1, c2;
int graph[MaxSize][MaxSize];
int rescue[MaxSize];
int dist[MaxSize], team[MaxSize];
int path[MaxSize];
int visit[MaxSize];
int mind = INF,maxt,cnt;
void Dijkstra()
{
    dist[c1] = 0;
    team[c1] = rescue[c1];
    int set1[MaxSize];
    int min, i, j, u = 0;
    for (i = 0; i < n; i++)
    {
        dist[i] = graph[c1][i];
        if (dist[i] != INF && i != c1)
            team[i] = team[c1] + rescue[i];
        set1[i] = 0;
    }
    set1[c1] = 1;
    for (i = 0; i < n; ++i)
    {
        min = INF;
        for (j = 0; j < n; ++j)
        {
            if (set1[j] == 0 && dist[j] < min)
            {
                u = j;
                min = dist[j];
            }
        }
        set1[u] = 1;
        //以u为中间节点考虑未加入的结点
        for (j = 0; j < n; ++j)
        {
            if (set1[j] == 0 && dist[u] + graph[u][j] < dist[j])
            {
                dist[j] = dist[u] + graph[u][j];
                team[j] = team[u] + rescue[j];
                path[j] = path[u];
            }
            else if (set1[j] == 0 && dist[u] + graph[u][j] == dist[j])
            {
                path[j] += path[u];
                if (team[j] < team[u] + rescue[j])
                    team[j] = team[u] + rescue[j];
            }
        }
    }
}
void dfs(int c1,const int c2,int dist,int weit)
{
    if(c1 == c2)
    {
        if(dist < mind)
        {
            cnt = 1;
            mind = dist;
            maxt = weit;
        }
        else if (dist == mind)
        {   
            ++cnt;
            if(maxt < weit)
                maxt = weit;
        }
        return;
    }

    int i;
    if(dist > mind) return ;
    for(i = 0; i < n; ++ i)
    {
        if(visit[i] == 0 && graph[c1][i] != INF)
        {
            visit[i] = 1;
            dfs(i,c2,dist+graph[c1][i],weit+rescue[i]);
            visit[i] = 0;
        }
    }
}
int main()
{
    cin >> n >> m >> c1 >> c2;
    int i;
    for (i = 0; i < n; i++)
    {
        cin >> rescue[i];
    }
    int a, b;
    for (i = 0; i < n; i++)
    {
        dist[i] = INF;
        path[i] = 1;
        team[i] = rescue[i];
        for (int j = 0; j < n; j++)
            graph[i][j] = INF;
    }
    for (i = 0; i < m; i++)
    {
        cin >> a >> b;
        cin >> graph[a][b];
        graph[b][a] = graph[a][b];
    }
    // Dijkstra();
    // cout << path[c2] << " " << team[c2] << endl;
    dfs(c1,c2,0,rescue[c1]);
    cout << cnt << " " << maxt << endl;
    return 0;
}